package com.zzyl.nursing.mapper;

import java.util.List;
import com.zzyl.nursing.domain.NursingPlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.domain.NursingProjectPlan;
import com.zzyl.nursing.vo.NursingPlanAllVo;
import com.zzyl.nursing.vo.NursingProjectPlanVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 护理计划Mapper接口
 * 
 * @author tomorrow
 * @date 2024-12-30
 */
@Mapper
public interface NursingPlanMapper extends BaseMapper<NursingPlan>
{
    /**
     * 查询护理计划
     * 
     * @param id 护理计划主键
     * @return 护理计划
     */
    public NursingPlan selectNursingPlanById(Long id);

    /**
     * 查询护理计划列表
     * 
     * @param nursingPlan 护理计划
     * @return 护理计划集合
     */
    public List<NursingPlan> selectNursingPlanList(NursingPlan nursingPlan);

    /**
     * 新增护理计划
     * 
     * @param nursingPlan 护理计划
     * @return 结果
     */
    public int insertNursingPlan(NursingPlan nursingPlan);

    /**
     * 修改护理计划
     * 
     * @param nursingPlan 护理计划
     * @return 结果
     */
    public int updateNursingPlan(NursingPlan nursingPlan);

    /**
     * 删除护理计划
     * 
     * @param id 护理计划主键
     * @return 结果
     */
    public int deleteNursingPlanById(Long id);

    /**
     * 批量删除护理计划
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteNursingPlanByIds(Long[] ids);

    /**
     * 批量插入项目计划
     * @param projectPlans
     * @param id
     * @return
     */
    int insertBatch(@Param("list") List<NursingProjectPlan> projectPlans,@Param("planId") Long id);


    /**
     * 根据计划id查询项目计划
     * @param planId
     * @return
     */
    @Select("select id, plan_id, project_id, execute_time, execute_cycle, execute_frequency from nursing_project_plan where plan_id = #{planId} ")
    List<NursingProjectPlanVo> selectProjectPlanByPlanId(@Param("planId") Long planId);

    /**
     * 根据计划id删除护理计划关联表
     * @param planId 护理计划id
     */
    void deleteByPlanId(@Param("planId")Long planId);


    /**
     * 根据护理计划id批量删除护理计划关联的项目计划
     * @param list
     */
    void deleteByPlanIds(@Param("ids") List<Long> list);

    /**
     * 查询全部护理计划
     * @return
     */
    @Select(" select create_by,create_time, id,sort_no,plan_name, status from nursing_plan where status = 1 ")
    List<NursingPlanAllVo> selectAllList();
}
